<template>
    <div>
    <p style="font-weight: bold" class="interfaceHead"><i class="el-icon-s-promotion"></i>处罚下发</p>
    <el-divider></el-divider>
    <el-form ref="form" :model="formPun" label-width="80px">
        <el-form-item label="单位名称">
            <el-input placeholder="请输入注册企业单位名称" v-model="formPun.companyName"></el-input>
        </el-form-item>


        <el-form-item label="处罚时间">
            <el-input placeholder="请输入xxxx年" v-model="formPun.year"></el-input>
            <el-input placeholder="请输入xx月" v-model="formPun.month"></el-input>
            <el-input placeholder="请输入xx日" v-model="formPun.day"></el-input>
        </el-form-item>

        <el-form-item>
            <el-upload
                    action="/fine/uploadFile"
                    ref="uploadDemo"
                    list-type="picture-card"
                    :auto-upload="false"
                    :headers="headers"
                    multiple="false">
                <i slot="default" class="el-icon-plus"></i>
                <div slot="file" slot-scope="{file}">
                    <img
                            class="el-upload-list__item-thumbnail"
                            :src="file.url" alt="">
                </div>
            </el-upload>
        </el-form-item>

        <el-form-item label="处罚措施">
            <el-input placeholder="请输入处罚措施" v-model="formPun.method"></el-input>
        </el-form-item>
        <el-button type="primary" @click="submmitPun">提交</el-button>
    </el-form>
    </div>
</template>

<script>
    export default {
        name: "HealthSupPunish",
        data() {
            return {
                formPun: {
                    companyName: '',
                    url: '',
                    year:'',
                    month:'',
                    day:'',
                    method:''
                },
            }
        },
        computed: {
            headers: function () {
                return {
                    "Authorization": `${localStorage.getItem('token')}`
                }
            }
        },
        methods: {
            submmitPun() {
                this.$refs.form.validate((valid) => {
                    if (valid) {
                        const _this = this;
                        this.postRequest('/fine/upload', this.formPun).then(resp => {
                            if (resp) {
                                _this.$refs.uploadDemo.submit();
                                if (resp) {
                                    console.log(resp)
                                         this.$message({
                                        message: '提交成功',
                                        type: 'success'
                                         });
                                }
                            }
                        })

                    } else {
                        this.$message.error('提交失败！');
                        return false;
                    }
                });
            },

        }
    }
</script>

<style scoped>

</style>